#!/bin/bash
#https://github.com/docker-practice/docker-registry-cn-mirror-test/blob/master/.github/workflows/ci.yaml
docker version
docker info

registrys="
docker.901020.xyz
dockerhub.icu
docker.m.daocloud.io
docker.io
dockerproxy.com
docker.nju.edu.cn
docker.mirrors.sjtug.sjtu.edu.cn
docker.mirrors.ustc.edu.cn
dockerhub.timeweb.cloud
hub-mirror.c.163.com
huecker.io
noohub.ru
mirror.baidubce.com
mirror.gcr.io
registry-1.docker.io
registry.hub.docker.com
ua6hh03f.mirror.aliyuncs.com
"
image="library/nginx:1.25.1-alpine"

for registry in $registrys
do
   echo ::group::Test $registry/$image
   docker pull $registry/$image \
     && (echo -e "\033[32m$registry is good\033[0m" \
        ; echo "::warning file=README.md,line=1,col=0::OK [ $registry ] is good") \
     || (echo -e "\033[31m$registry is outdated\033[0m" \
        ; echo "::error file=README.md,line=1,col=0::X [ $registry ] is outdated")
   docker rmi $registry/$image || true
   echo ::endgroup::
done
